package com.lg.business.util;
import java.io.Serializable;

public class RespBody implements Serializable {
    private static final long serialVersionUID = 2126864177793957077L;
    private Integer code;
    private String msg;
    private Object data;
    private Long timestamp;

    public RespBody(RespBody.Builder builder) {
        this.setCode(builder.code);
        this.setMsg(builder.msg);
        this.setData(builder.data);
        this.setTimestamp(builder.timestamp);
    }

    public RespBody() {
    }

    public static RespBody success() {
        return (new RespBody.Builder()).code(RespCode.SUCCESS.getCode()).msg(RespCode.SUCCESS.getMsg()).putTimeStamp().build();
    }

    public static <T> RespBody success(T data) {
        return (new RespBody.Builder()).code(RespCode.SUCCESS.getCode()).msg(RespCode.SUCCESS.getMsg()).data(data).putTimeStamp().build();
    }

    public static <T> RespBody success(int code, String msg, T data) {
        return (new RespBody.Builder()).code(code).msg(msg).data(data).putTimeStamp().build();
    }

    public static RespBody fail() {
        return (new RespBody.Builder()).code(RespCode.ERROR.getCode()).msg(RespCode.ERROR.getMsg()).putTimeStamp().build();
    }

    public static RespBody fail(String msg) {
        return (new RespBody.Builder()).code(RespCode.ERROR.getCode()).msg(msg).putTimeStamp().build();
    }

    public static RespBody fail(int code, String msg) {
        return (new RespBody.Builder()).code(code).msg(msg).putTimeStamp().build();
    }

    public static RespBody fail(RespCode dsxResCode) {
        return (new RespBody.Builder()).code(dsxResCode.getCode()).msg(dsxResCode.getMsg()).putTimeStamp().build();
    }

    public Integer getCode() {
        return this.code;
    }

    public String getMsg() {
        return this.msg;
    }

    public Object getData() {
        return this.data;
    }

    public Long getTimestamp() {
        return this.timestamp;
    }

    public void setCode(final Integer code) {
        this.code = code;
    }

    public void setMsg(final String msg) {
        this.msg = msg;
    }

    public void setData(final Object data) {
        this.data = data;
    }

    public void setTimestamp(final Long timestamp) {
        this.timestamp = timestamp;
    }

    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof RespBody)) {
            return false;
        } else {
            RespBody other = (RespBody)o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                label59: {
                    Object this$code = this.getCode();
                    Object other$code = other.getCode();
                    if (this$code == null) {
                        if (other$code == null) {
                            break label59;
                        }
                    } else if (this$code.equals(other$code)) {
                        break label59;
                    }

                    return false;
                }

                Object this$msg = this.getMsg();
                Object other$msg = other.getMsg();
                if (this$msg == null) {
                    if (other$msg != null) {
                        return false;
                    }
                } else if (!this$msg.equals(other$msg)) {
                    return false;
                }

                Object this$data = this.getData();
                Object other$data = other.getData();
                if (this$data == null) {
                    if (other$data != null) {
                        return false;
                    }
                } else if (!this$data.equals(other$data)) {
                    return false;
                }

                Object this$timestamp = this.getTimestamp();
                Object other$timestamp = other.getTimestamp();
                if (this$timestamp == null) {
                    if (other$timestamp != null) {
                        return false;
                    }
                } else if (!this$timestamp.equals(other$timestamp)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(final Object other) {
        return other instanceof RespBody;
    }


    public String toString() {
        return "RespBody(code=" + this.getCode() + ", msg=" + this.getMsg() + ", data=" + this.getData() + ", timestamp=" + this.getTimestamp() + ")";
    }

    private static class Builder {
        private Integer code;
        private String msg;
        private Object data;
        private Long timestamp;

        private Builder() {
        }

        private RespBody.Builder code(int code) {
            this.code = code;
            return this;
        }

        private RespBody.Builder data(Object data) {
            this.data = data;
            return this;
        }

        private RespBody.Builder msg(String msg) {
            this.msg = msg;
            return this;
        }

        private RespBody.Builder putTimeStamp() {
            this.timestamp = System.currentTimeMillis();
            return this;
        }

        private RespBody build() {
            return new RespBody(this);
        }
    }
}